package com.shawn.integeration.batch.file.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobExecutionListener;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

/**
 * @author shawn
 * @description: 学生信息读取任务监听器
 * @date 2024/1/13
 */

@Slf4j
@Component
public class StudentReaderJobListener implements JobExecutionListener {
    private LocalDateTime start;
    private LocalDateTime end;

    @Override
    public void beforeJob(JobExecution jobExecution) {
        start = LocalDateTime.now();
        log.info("student reader job start...");
    }

    @Override
    public void afterJob(JobExecution jobExecution) {
        end = LocalDateTime.now();
        log.info("student reader job end,cost {} ms", ChronoUnit.MILLIS.between(start, end));

    }
}
